<?php

/*
 * @copyright :     Ienter asia Technologies
 * @author :        Quyet
 * @version         v.1.0
 * @created         24/7/2014
 * @Description :   sub string
 */
if (!function_exists('subString')) {

    function subString($str = '', $n = 15, $more = '...') {
        $temp = $str;
        if ($str && mb_strlen($str) > $n) {
            $temp = mb_substr($str, 0, $n) . $more;
        }
        return $temp;
    }

}
/*
 * @copyright :     Ienter asia Technologies
 * @author :        Quyet
 * @version         v.1.0
 * @created         24/7/2014
 * @Description :   double quotes
 */
if (!function_exists('dQuotes')) {

    function dQuotes($str = '', $flags = ENT_QUOTES) {
        $temp = $str;
        if ($str) {
            $temp = htmlspecialchars($str, $flags);
        }
        return $temp;
    }

}

/*
 * @copyright :     Ienter asia Technologies
 * @author :        Quyet
 * @version         v.1.0
 * @created         24/7/2014
 * @Description :   double quotes
 */
if (!function_exists('dQuotes')) {

    function dQuotes($str = '', $flags = ENT_QUOTES) {
        $temp = $str;
        if ($str) {
            $temp = htmlspecialchars($str, $flags);
        }
        return $temp;
    }

}

/*
 * @author :        Quyet
 * @created:        30/6/2014
 * @Description:    set date 
 * @Input :         (String) $string
 *                  (String) $format
 * @Output :        String
 */

function setTime($string = '', $format = 'H:i') {
    if ($string == '' || $string == '00:00:00') {
        return FALSE;
    } else {
        return date($format, strtotime($string));
    }
}

/**
 * @author Thanh NV        
 * @created:2014/06/23
 * @function check_float_string 
 * @param: $str          
 * @Output: TRUE or False
 * @This function return TRUE or False
 */
function check_float_string($str) {
    $pairs = explode('.', $str);
    if (is_array($pairs) && count($pairs) == 2) {
        return ( is_numeric($pairs[0]) && is_numeric($pairs[1])) ? true : false;
    } elseif (is_array($pairs) && count($pairs) == 1) {
        return true;
    } else {
        return false;
    }
}

?>